﻿Option Explicit On
Option Strict On

Imports TreeCreeper01Interfaces
Imports System.Drawing

Public Class cTaxonomicSpecies

    Implements ITaxonomicSpecies

    Private Shared ColourRandomiser As New Random

    Protected pUniqueKey As String
    Protected pName As String
    Private mIsColourCalculated As Boolean
    Private mColour As System.Drawing.Color

    Public Sub New(ByVal UniqueKey As String, ByVal Name As String)
        pUniqueKey = UniqueKey
        pName = Name
        GenerateColour()
    End Sub

    Public ReadOnly Property Name() As String Implements ITaxonomicSpecies.Name
        Get
            Return pName
        End Get
    End Property

    Public ReadOnly Property UniqueKey() As String Implements ITaxonomicSpecies.UniqueKey
        Get
            Return pUniqueKey
        End Get
    End Property

    Public ReadOnly Property Colour() As System.Drawing.Color Implements ITaxonomicSpecies.DisplayColour
        Get
            Return mColour
        End Get
    End Property

    Private Sub GenerateColour()

        Dim ColourR As Byte
        Dim ColourG As Byte
        Dim ColourB As Byte

        ColourR = CByte(ColourRandomiser.Next(0, 255))
        ColourG = CByte(ColourRandomiser.Next(0, 255))
        If ColourR > 200 Then
            If ColourG > 200 Then
                ColourB = CByte(ColourRandomiser.Next(0, 150))
            Else
                ColourB = CByte(ColourRandomiser.Next(0, 255))
            End If
        End If

        mColour = Color.FromArgb(255, ColourR, ColourG, ColourB)

    End Sub

End Class
